<template>
  <!--视图-->
  <div>

    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="formInline.userName" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="formInline.password" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="loginName">登录</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: "LoginView",
  data() {//属性
    return {
      formInline:{},
    }
  }, methods: {//自定义方法
    loginName(){
      this.axios.post("system/user/loginName",this.formInline).then(res=>{
        if(res.data.code==200){
          this.$message.success(res.data.msg);
          sessionStorage.setItem("token",res.data.data);
          this.$router.push("user");
        }else {
          this.$message.error(res.data.msg);
        }
      })
    }
  }, created() { //钩子函数

  }
}
</script>

<style scoped>

</style>